package com.zhoug.zmuidemo.ui;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;

import com.zhoug.zmui.ZMUILinePathView;
import com.zhoug.zmuidemo.R;

public class LinePathActivity extends AppCompatActivity {

    private ZMUILinePathView mLinePathView1;
    private Button mBtnClear;
    private ImageView mImageView1;
    private Button mBtnConfirm;
    private Button mBtnConfirmClip;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_line_path);
        findViews();

        mBtnClear.setOnClickListener(v->clear());
        mBtnConfirm.setOnClickListener(v->confirm());
        mBtnConfirmClip.setOnClickListener(v->confirmClip());

    }

    private void findViews() {
        mLinePathView1 = findViewById(R.id.linePathView1);
        mBtnClear = findViewById(R.id.btn_clear);
        mImageView1 = findViewById(R.id.imageView1);
        mBtnConfirm = findViewById(R.id.btn_confirm);
        mBtnConfirmClip = findViewById(R.id.btn_confirm_clip);
    }

    private void clear(){
        mLinePathView1.clear();
    }

    private void confirm(){
        mImageView1.setImageBitmap(mLinePathView1.getBitmap());
    }

    private void confirmClip(){
        mImageView1.setImageBitmap(mLinePathView1.getClipBlankBitmap(30));
    }
}